<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('抽奖活动列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="lottery-form">
				<div class="select-list">
					<ul>
						<li>
							抽奖标题：<input type="text" name="lotteryTitle"/>
						</li>
						<li>
							抽奖内容：<input type="text" name="lotteryContent"/>
						</li>
						<li>
							<label>查询时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="请输入查询时间" name="queryDate"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="biz:lottery:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="biz:lottery:edit">
                <i class="fa fa-edit"></i> 修改
            </a>-->
			<!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:lottery:remove">
                <i class="fa fa-remove"></i> 删除
            </a>-->
			<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="biz:lottery:export">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table-lottery"></table>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('biz:lottery:edit')}]];
	var removeFlag = [[${@permission.hasPermi('biz:lottery:remove')}]];
	var prefix = ctx + "biz/lottery";
	var prefix2 = ctx + "biz/lotteryPrize";
	var prefix3 = ctx + "biz/lotteryResult";
	var prefix4 = ctx + "biz/lotteryLog";


	$(function() {
		var options = {
			id: "bootstrap-table-lottery",
			url: prefix + "/list",
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			exportUrl: prefix + "/export",
			sortName: "endTime",
			sortOrder: "desc",
			modalName: "抽奖",
			columns: [
				/*{
                    field: 'lotteryId',
                    title: '抽奖活动ID'
                },*/
				{
					field: 'lotteryTitle',
					title: '抽奖活动标题',
					sortable: true
				},
				{
					field: 'lotteryContent',
					title: '抽奖活动内容',
					sortable: true
				},
				{
					field: 'beginTime',
					title: '开始时间',
					sortable: true
				},
				{
					field: 'endTime',
					title: '结束时间',
					sortable: true
				},
				{
					field: 'crteTime',
					title: '创建时间',
					sortable: true
				},
				{
					field: 'crterName',
					title: '创建人',
					sortable: true
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.lotteryId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="lotteryPrize(\'' + row.lotteryId + '\')"><i class="fa fa-bars"></i>奖品维护</a> ');
						actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="lotteryResult(\'' + row.lotteryId + '\')"><i class="fa fa-bank"></i>中奖结果</a> ');
						actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="lotteryLog(\'' + row.lotteryId + '\')"><i class="fa fa-bank"></i>抽奖记录</a> ');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.lotteryId + '\')"><i class="fa fa-remove"></i>删除</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});

	/* 奖品维护 */
	function lotteryPrize(lotteryId) {
		var url = prefix2 + '/' + lotteryId;
		$.modal.open("抽奖奖品维护", url, '1200', '700');
	}
	/* 中奖结果 */
	function lotteryResult(lotteryId) {
		var url = prefix3 + '/' + lotteryId;
		$.modal.open("中奖结果信息", url, '1200', '700');
	}
	/* 抽奖记录 */
	function lotteryLog(lotteryId) {
		var url = prefix4 + '/' + lotteryId;
		$.modal.open("抽奖记录", url, '1200', '700');
	}
</script>
</body>
</html>